import request from '@/utils/request'

/**
 * 部门列表
 */
export const reqShowDepartments = () => {
  return request({
    url: '/company/department'
  })
}

/**
 * 删除部门
 * @param {*} id 部门ID
 */
export const reqDelDepartments = (id) => {
  return request({
    method: 'delete',
    url: '/company/department/' + id
  })
}

/**
 * 获取员工简单列表
 */
export const reqUserSimpleList = () => {
  return request({
    url: '/sys/user/simple'
  })
}

/**
 * 新增部门
 * @param {*} data 要传的参数：{code:'',introduce:'',manager:'',name:'',pid:''}
 * from中有前四个参数，最后一个pid无
 */
export const reqAddDepartment = (data) => {
  return request({
    method: 'post',
    url: '/company/department',
    data
  })
}

/**
 * 获取部门详情 【用于编辑部门中的回显】
 * @param {*} id 部门ID
 */
export const reqDepartmentDetail = (id) => {
  return request({
    url: '/company/department/' + id
  })
}

/**
 * 更新部门详情 【编辑部门】
 * @param {*} form 部门总数据
 */
export const reqUpdateDepartment = (form) => {
  return request({
    method: 'put',
    url: '/company/department/' + form.id,
    data: form
  })
}
